package thesis.filesharing.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.datanucleus.annotations.Unowned;

@Entity
public class Group {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Key groupKey;
	
	@Basic
	private String groupName;
	
	@Basic
	private String topicName;
	
	@Basic
	private Set<Key> groupMembers = new HashSet<Key>();
	
	@Unowned
	@ManyToOne
	private Student groupLeader;
	
	@ManyToOne(fetch = FetchType.LAZY)
	private Clazz clazz;
	
	@Unowned
	@OneToMany(fetch = FetchType.LAZY)
	private Set<ExerciseFile> exerciseFiles = new HashSet<ExerciseFile>();

	public Group() {
		
	}
	
	public Group(Key groupKey, String groupName, String topicName) {
		this.groupKey = groupKey;
		this.groupName = groupName;
		this.topicName = topicName;
	}

	public Group(Key groupKey, String groupName, Set<Key> groupMembers, Student groupLeader, Clazz clazz) {
		this.groupKey = groupKey;
		this.groupName = groupName;
		this.groupMembers = groupMembers;
		this.groupLeader = groupLeader;
		this.clazz = clazz;
	}

	public Group(String groupName, Set<Key> groupMembers, Student groupLeader, 
			Clazz clazz, Set<ExerciseFile> exerciseFiles) {
		this.groupName = groupName;
		this.groupMembers = groupMembers;
		this.groupLeader = groupLeader;
		this.clazz = clazz;
		this.exerciseFiles = exerciseFiles;
	}

	public Group(String groupName, String topicName, Set<Key> groupMembers,
			Student groupLeader, Clazz clazz, Set<ExerciseFile> exerciseFiles) {
		this.groupName = groupName;
		this.topicName = topicName;
		this.groupMembers = groupMembers;
		this.groupLeader = groupLeader;
		this.clazz = clazz;
		this.exerciseFiles = exerciseFiles;
	}

	public Key getGroupKey() {
		return groupKey;
	}

	public void setGroupKey(Key groupKey) {
		this.groupKey = groupKey;
	}

	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	public String getTopicName() {
		return topicName;
	}

	public void setTopicName(String topicName) {
		this.topicName = topicName;
	}

	public Set<Key> getGroupMembers() {
		return groupMembers;
	}

	public void setGroupMembers(Set<Key> groupMembers) {
		this.groupMembers = groupMembers;
	}

	public Student getGroupLeader() {
		return groupLeader;
	}

	public void setGroupLeader(Student groupLeader) {
		this.groupLeader = groupLeader;
	}

	public Clazz getClazz() {
		return clazz;
	}

	public void setClazz(Clazz clazz) {
		this.clazz = clazz;
	}

	public Set<ExerciseFile> getExerciseFiles() {
		return exerciseFiles;
	}

	public void setExerciseFiles(Set<ExerciseFile> exerciseFiles) {
		this.exerciseFiles = exerciseFiles;
	}
}
